// package: learn-go
// filename: main
// author: Administrator@gmail.com
// time: 2023/8/9 17:04
package main

import (
	"bytes"
	"fmt"
	"log"
	"os/exec"
)

func getNodeVersion() (string, error) {
	cmd := exec.Command("node", "-v")

	var out bytes.Buffer
	cmd.Stdout = &out
	err := cmd.Run()
	if err != nil {
		log.Fatal(err)
	}

	return out.String(), nil
}

func main() {
	nodeVersion, err := getNodeVersion()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Node.js version: %s\n", nodeVersion)
}
